package net.protocol.diameter.avp;

import java.nio.ByteBuffer;

/**
 * <pre>
 *    DiameterIdentity
 *       The DiameterIdentity format is derived from the OctetString AVP
 *       Base Format.
 * 
 *          DiameterIdentity  = FQDN
 * 
 *       DiameterIdentity value is used to uniquely identify a Diameter
 *       node for purposes of duplicate connection and routing loop
 *       detection.
 * 
 *       The contents of the string MUST be the FQDN of the Diameter node.
 *       If multiple Diameter nodes run on the same host, each Diameter
 *       node MUST be assigned a unique DiameterIdentity.  If a Diameter
 *       node can be identified by several FQDNs, a single FQDN should be
 *       picked at startup, and used as the only DiameterIdentity for that
 *       node, whatever the connection it is sent on.
 * </pre>
 * 
 * @author jinhongw@gmail.com
 */
public class DiameterIdentity extends OctetString  {

    /**
     * @param code AVP Code
     * @param identity AVP Data
     */
	public DiameterIdentity(int code, String identity) {
    	super(code, identity);
    }

    /**
     * @param code     AVP Code
     * @param vendorId Vendor-ID
     * @param identity     AVP Data
     */
	public DiameterIdentity(int code, int vendorId, String identity) {
        super(code, vendorId, identity);
    }

    /**
     * Creates a new <code>DiameterIdentity</code> with the given DiameterAVPHeader and source ByteBuffer
     *
     * @param header Diameter AVP Header
     * @param src The buffer from which bytes are to be retrieved
     */
    DiameterIdentity(DiameterAVPHeader header, ByteBuffer src) {
        super(header, src);
    }

    @Override
    public final DataFormat getType() {
        return DataFormat.DiameterIdentity;
    }

    @Override
    public String getName() {
        return DataFormat.DiameterIdentity.name();
    }
}
